home *** CD-ROM | disk | FTP | other *** search
/ Trusted Irix /B 4.0.4 / Trusted-Irix B-4.0.1.iso / dist / eoe1.idb / usr / include / sys / fpu.h.z / fpu.h
C/C++ Source or Header  |  1992-04-03  |  7KB  |  292 lines

  1. #ifndef __SYS_FPU_H__
  2. #define __SYS_FPU_H__
  3.  
  4. /**************************************************************************
  5.  *                                      *
  6.  *          Copyright (C) 1990-1992 Silicon Graphics, Inc.          *
  7.  *                                      *
  8.  *  These coded instructions, statements, and computer programs  contain  *
  9.  *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
  10.  *  are protected by Federal copyright law.  They  may  not be disclosed  *
  11.  *  to  third  parties  or copied or duplicated in any form, in whole or  *
  12.  *  in part, without the prior written consent of Silicon Graphics, Inc.  *
  13.  *                                      *
  14.  **************************************************************************/
  15.  
  16. /* ------------------------------------------------------------------ */
  17. /* | Copyright Unpublished, MIPS Computer Systems, Inc.  All Rights | */
  18. /* | Reserved.  This software contains proprietary and confidential | */
  19. /* | information of MIPS and its suppliers.  Use, disclosure or     | */
  20. /* | reproduction is prohibited without the prior express written   | */
  21. /* | consent of MIPS.                                               | */
  22. /* ------------------------------------------------------------------ */
  23. /* %Q% %I% %M% */
  24.  
  25. #ident "$Revision: 5.4 $"
  26.  
  27. /*
  28.  * fpu.h -- fpu specific defines
  29.  */
  30.  
  31. #ifdef LANGUAGE_C
  32. /*
  33.  * Structure and constant definisions for floating-point instructions.
  34.  */
  35. union fpu_instr {
  36.     unsigned long instr;
  37.  
  38.     struct {
  39. #ifdef MIPSEB
  40.         unsigned op : 6;
  41.         unsigned base : 5;
  42.         unsigned rt : 5;
  43.         signed immed : 16;
  44. #endif /* MIPSEB */
  45. #ifdef MIPSEL
  46.         signed immed : 16;
  47.         unsigned rt : 5;
  48.         unsigned base : 5;
  49.         unsigned op : 6;
  50. #endif /* MIPSEL */
  51.     } itype;
  52.  
  53.     struct {
  54. #ifdef MIPSEB
  55.         unsigned op : 6;
  56.         unsigned sub : 5;
  57.         unsigned rt : 5;
  58.         unsigned rs : 5;
  59.         unsigned : 11;
  60. #endif /* MIPSEB */
  61. #ifdef MIPSEL
  62.         unsigned : 11;
  63.         unsigned rs : 5;
  64.         unsigned rt : 5;
  65.         unsigned sub : 5;
  66.         unsigned op : 6;
  67. #endif /* MIPSEL */
  68.     } mtype;
  69.  
  70.     struct {
  71. #ifdef MIPSEB
  72.         unsigned op : 6;
  73.         unsigned one : 1;
  74.         unsigned fmt : 4;
  75.         unsigned rt : 5;
  76.         unsigned rs : 5;
  77.         unsigned rd : 5;
  78.         unsigned func : 6;
  79. #endif /* MIPSEB */
  80. #ifdef MIPSEL
  81.         unsigned func : 6;
  82.         unsigned rd : 5;
  83.         unsigned rs : 5;
  84.         unsigned rt : 5;
  85.         unsigned fmt : 4;
  86.         unsigned one : 1;
  87.         unsigned op : 6;
  88. #endif /* MIPSEL */
  89.     } rtype;
  90. };
  91. #endif /* LANGUAGE_C */
  92.  
  93. #define FMT_SINGLE    0
  94. #define FMT_DOUBLE    1
  95. #define FMT_EXTENDED    2
  96. #define FMT_QUAD    3
  97. #define FMT_WORD    4
  98. #define FMT_MAX        4
  99.  
  100. #define FUNC_ADD    0
  101. #define FUNC_SUB    1
  102. #define FUNC_MUL    2
  103. #define FUNC_DIV    3
  104.  
  105. #define    FUNC_SQRT    4
  106. #define    FUNC_ABS    5
  107. #define    FUNC_MOV    6
  108. #define FUNC_NEG    7
  109.  
  110. #define FUNC_ROUND    0x0c
  111. #define FUNC_TRUNC    0x0d
  112. #define FUNC_CEIL    0x0e
  113. #define FUNC_FLOOR    0x0f
  114.  
  115. #define FUNC_CVTS    0x20
  116. #define FUNC_CVTD    0x21
  117. #define FUNC_CVTE    0x22
  118. #define FUNC_CVTQ    0x23
  119. #define FUNC_CVTW    0x24
  120.  
  121. /*
  122.  * The func field of floating-point compare opcodes are FUNC_FC with
  123.  * some combination of conditions (COND_*).
  124.  */
  125. #define FUNC_FC        0x30
  126. #define COND_UN_MASK    0x1
  127. #define COND_EQ_MASK    0x2
  128. #define COND_LT_MASK    0x4
  129. #define COND_IN_MASK    0x8
  130.  
  131. /*
  132.  * The _MASK's are used to get a the specified field after it has been
  133.  * shifted by _SHIFT and then bit patterns above can be used to test
  134.  * the field.  These are useful in assembly code.
  135.  */
  136. #define    FPU_BASE_SHIFT    21
  137. #define    FPU_BASE_MASK    0x1f
  138. #define    FPU_FMT_SHIFT    21
  139. #define    FPU_FMT_MASK    0xf
  140. #define    FPU_RT_SHIFT    16
  141. #define    FPU_RT_MASK    0x1f
  142. #define    FPU_RT_FPRMASK    0x1e
  143. #define    FPU_RS_SHIFT    11
  144. #define    FPU_RS_MASK    0x1f
  145. #define    FPU_RS_FPRMASK    0x1e
  146. #define    FPU_RD_SHIFT    6
  147. #define    FPU_RD_MASK    0x1f
  148. #define    FPU_RD_FPRMASK    0x1e
  149.  
  150. #ifdef LANGUAGE_C
  151. /*
  152.  * These functions are used to get and set the floating-point control
  153.  * registers.  They are defined in the library module fp_control.s
  154.  */
  155. extern unsigned long get_fpc_csr();
  156. extern unsigned long set_fpc_csr();
  157. extern unsigned long get_fpc_irr();
  158. extern void set_fpc_led();
  159. extern unsigned long get_fpc_eir();
  160.  
  161. /*
  162.  * Structure and constant definisions for the floating-point control
  163.  * implementation and revision register (fpc_irr).
  164.  */
  165. union fpc_irr {
  166.     unsigned long fi_word;
  167.     struct {
  168. #ifdef MIPSEB
  169.         unsigned reserved : 16;
  170.         unsigned implementation : 8;
  171.         unsigned revision : 8;
  172. #endif /* MIPSEB */
  173. #ifdef MIPSEL
  174.         unsigned revision : 8;
  175.         unsigned implementation : 8;
  176.         unsigned reserved : 16;
  177. #endif /* MIPSEL */
  178.     } fi_struct;
  179. };
  180. #endif /* LANGUAGE_C */
  181.  
  182. /*
  183.  * Constants for the implementation fieid of the fpc_irr structure for the
  184.  * known implementations.
  185.  */
  186. #define IMPLEMENTATION_NONE    0    /* software */
  187. #define IMPLEMENTATION_R2360    1    /* board */
  188. #define IMPLEMENTATION_R2010    2    /* chip */
  189.  
  190. /*
  191.  * The constant IRR_IMP_MASK is to get at the implementation fieid of the
  192.  * implementation and revision register.  The other constants (IRR_IMP_*)
  193.  * are constants for the known implementations.
  194.  */
  195. #define IRR_IMP_MASK        0x0000ff00
  196.  
  197. #define IRR_IMP_NONE        0x00000000
  198. #define IRR_IMP_R2360        0x00000100
  199. #define IRR_IMP_R2010        0x00000200
  200.  
  201. /*
  202.  * Structure and constant definisions for the floating-point control
  203.  * control and status register (fpc_csr).
  204.  */
  205. #ifdef LANGUAGE_C
  206. union fpc_csr {
  207.     unsigned long fc_word;
  208.     struct {
  209. #ifdef MIPSEB
  210.         unsigned reserved0 : 7;
  211.         unsigned flush : 1;
  212.         unsigned condition : 1;
  213.         unsigned reserved1 : 5;
  214.  
  215.         unsigned ex_unimplemented : 1;
  216.         unsigned ex_invalid : 1;
  217.         unsigned ex_divide0 : 1;
  218.         unsigned ex_overflow : 1;
  219.         unsigned ex_underflow : 1;
  220.         unsigned ex_inexact : 1;
  221.  
  222.         unsigned en_invalid : 1;
  223.         unsigned en_divide0 : 1;
  224.         unsigned en_overflow : 1;
  225.         unsigned en_underflow : 1;
  226.         unsigned en_inexact : 1;
  227.  
  228.         unsigned se_invalid : 1;
  229.         unsigned se_divide0 : 1;
  230.         unsigned se_overflow : 1;
  231.         unsigned se_underflow : 1;
  232.         unsigned se_inexact : 1;
  233.  
  234.         unsigned rounding_mode : 2;
  235. #endif /* MIPSEB */
  236. #ifdef MIPSEL
  237.         unsigned rounding_mode : 2;
  238.  
  239.         unsigned se_inexact : 1;
  240.         unsigned se_underflow : 1;
  241.         unsigned se_overflow : 1;
  242.         unsigned se_divide0 : 1;
  243.         unsigned se_invalid : 1;
  244.  
  245.         unsigned en_inexact : 1;
  246.         unsigned en_underflow : 1;
  247.         unsigned en_overflow : 1;
  248.         unsigned en_divide0 : 1;
  249.         unsigned en_invalid : 1;
  250.  
  251.         unsigned ex_inexact : 1;
  252.         unsigned ex_underflow : 1;
  253.         unsigned ex_overflow : 1;
  254.         unsigned ex_divide0 : 1;
  255.         unsigned ex_invalid : 1;
  256.         unsigned ex_unimplemented : 1;
  257.  
  258.         unsigned reserved1 : 5;
  259.         unsigned condition : 1;
  260.         unsigned flush : 1;
  261.         unsigned reserved0 : 7;
  262. #endif /* MIPSEL */
  263.     } fc_struct;
  264. };
  265. #endif /* LANGUAGE_C */
  266.  
  267. /*
  268.  * Constants for the rounding_mode field of the fpc_csr
  269.  */
  270. #define ROUND_TO_NEAREST    0
  271. #define ROUND_TO_ZERO        1
  272. #define ROUND_TO_PLUS_INFINITY    2
  273. #define ROUND_TO_MINUS_INFINITY    3
  274.  
  275. /* Masks to get at the unimplemented exception */
  276. #define    FPCSR_UNIMP        0x00020000
  277. #define    FPCSR_EXCEPTIONS    0x0003f000    /* all exceptions */
  278. #define    FPCSR_ENABLES        0x00000f80
  279.  
  280. #ifdef LANGUAGE_ASSEMBLY
  281. /*
  282.  * Assembly register names for the floating-point control registers.
  283.  */
  284. #define fpc_irr    $0
  285. #define fpc_led    $0
  286. #define fpc_eir    $30
  287. #define fpc_csr    $31
  288.  
  289. #endif /* LANGUAGE_ASSEMBLY */
  290.  
  291. #endif /* __SYS_FPU_H__ */
  292.